import Vue from 'vue';
import * as recommend from '../api/recommend';
import * as hotSong from '../api/hot-song'
import * as search from '../api/search-list'
import * as datalist from '../api/musicdetails'

export default new Vue ({
    data () {
        return {
            // 推荐歌曲
            playlist:[],
            // 新歌列表
            newSonglist:[],
            // 热歌列表
            searchhotlist:[],
            // 热搜列表
            SearchList:[],
            // 搜索建议
            searchsuggest:[],
            // 最佳匹配
            searchmultimatch:{}, 
            // 搜索结果
            searchlist:[],
            // 推荐详情
            detailslist:[]
        }
    },
    created () {
        // 改变数据 跟新歌单
        this.$on('updateplaylist' , async() => {
            this.playlist = await recommend.getPlaylist()
        })
        // 更新新歌歌列表
        this.$on('updateNewSonglist' , async () => {
            this.newSonglist = await recommend.getNewSongList()
        })
        // 更新热歌列表
        this.$on('updateHotSongList', async () => {
            this.hotSongList = await hotSong.getHotSongList()



        })
        // 更新热搜列表
        this.$on('updateSearchHotList', async () => {
            this.SearchList = await search.getSearchHot()
        })
        // 更新搜索建议
        this.$on('updateSearchSuggest', async (val) => {
            this.searchsuggest = await search.getSearchSuggest(val)
        })
        // 更新最匹配
        this.$on('updateSearchMultimatch', async () => {
            this.searchmultimatch = await search.getsearchmultimatch()
        })
        // 更新全部
        this.$on('updateSearchList', async (val) => {
            this.searchlist = await search.getsearchlist(val)
        })

        // 推荐详情
        this.$on('musicdetails', async (id) => {
            this.detailslist = await datalist.getdetalist(id)
        })  
    }
})